package com.yc.supermarket.service.impl;


import com.yc.supermarket.entity.Report;
import com.yc.supermarket.mapper.ReportMapper;
import com.yc.supermarket.service.IReportService;
import com.yc.supermarket.util.MybatisUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ReportServiceImpl implements IReportService {
    private ReportMapper mapper;
    @Override
    public Map<String,Object> findyear(Report report){
        SqlSession session= MybatisUtil.getSession();
        mapper=session.getMapper(ReportMapper.class);
        List<Report> list=mapper.findyear(report);
        Map<String,Object> map=new HashMap<>();
        if(list.isEmpty() || list==null){
            map.put("code",0);
        }else{
            map.put("code",1);
        }
        map.put("data",list);
        return map;
    }

    @Override
    public Map<String,Object> findMonth(Report report){
        SqlSession session= MybatisUtil.getSession();
        mapper=session.getMapper(ReportMapper.class);
        List<Report> list=mapper.findmonth(report);
        Map<String,Object> map=new HashMap<>();
        if(list.isEmpty() || list==null){
            map.put("code",0);
        }else{
            map.put("code",1);
        }
        map.put("data",list);
        return map;
    }
}
